using System;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Xml;
using System.Xml.Serialization;
using SubSonic;
using SubSonic.Utilities;

//Generated on 24/06/2007 16:38:56 by Rupert

namespace SubSonicMembershipProvider.DataObjects{
    /// <summary>
    /// Strongly-typed collection for the UserMembership class.
    /// </summary>
    [Serializable]
    public partial class UserMembershipCollection : ActiveList<UserMembership, UserMembershipCollection> 
    {       
        public UserMembershipCollection() {}

    }

    /// <summary>
    /// This is an ActiveRecord class which wraps the UserMembership table.
    /// </summary>
    [Serializable]
    public partial class UserMembership : ActiveRecord<UserMembership>
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }

	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }

                return BaseSchema;
            }

        }

    	
        private static void GetTableSchema() 
	    {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
				TableSchema.Table schema = new TableSchema.Table("UserMembership", TableType.Table, DataService.GetInstance("MembershipProvider"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = @"dbo";
                //columns
                
                TableSchema.TableColumn colvarUserId = new TableSchema.TableColumn(schema);
                colvarUserId.ColumnName = "UserId";
                colvarUserId.DataType = DbType.Int32;
                colvarUserId.MaxLength = 0;
                colvarUserId.AutoIncrement = true;
                colvarUserId.IsNullable = false;
                colvarUserId.IsPrimaryKey = true;
                colvarUserId.IsForeignKey = false;
                colvarUserId.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarUserId);
                
                TableSchema.TableColumn colvarUserName = new TableSchema.TableColumn(schema);
                colvarUserName.ColumnName = "UserName";
                colvarUserName.DataType = DbType.String;
                colvarUserName.MaxLength = 256;
                colvarUserName.AutoIncrement = false;
                colvarUserName.IsNullable = false;
                colvarUserName.IsPrimaryKey = false;
                colvarUserName.IsForeignKey = false;
                colvarUserName.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarUserName);
                
                TableSchema.TableColumn colvarLoweredUserName = new TableSchema.TableColumn(schema);
                colvarLoweredUserName.ColumnName = "LoweredUserName";
                colvarLoweredUserName.DataType = DbType.String;
                colvarLoweredUserName.MaxLength = 256;
                colvarLoweredUserName.AutoIncrement = false;
                colvarLoweredUserName.IsNullable = false;
                colvarLoweredUserName.IsPrimaryKey = false;
                colvarLoweredUserName.IsForeignKey = false;
                colvarLoweredUserName.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarLoweredUserName);
                
                TableSchema.TableColumn colvarMobileAlias = new TableSchema.TableColumn(schema);
                colvarMobileAlias.ColumnName = "MobileAlias";
                colvarMobileAlias.DataType = DbType.String;
                colvarMobileAlias.MaxLength = 16;
                colvarMobileAlias.AutoIncrement = false;
                colvarMobileAlias.IsNullable = true;
                colvarMobileAlias.IsPrimaryKey = false;
                colvarMobileAlias.IsForeignKey = false;
                colvarMobileAlias.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarMobileAlias);
                
                TableSchema.TableColumn colvarIsAnonymous = new TableSchema.TableColumn(schema);
                colvarIsAnonymous.ColumnName = "IsAnonymous";
                colvarIsAnonymous.DataType = DbType.Boolean;
                colvarIsAnonymous.MaxLength = 0;
                colvarIsAnonymous.AutoIncrement = false;
                colvarIsAnonymous.IsNullable = false;
                colvarIsAnonymous.IsPrimaryKey = false;
                colvarIsAnonymous.IsForeignKey = false;
                colvarIsAnonymous.IsReadOnly = false;
                
						colvarIsAnonymous.DefaultSetting = @"((0))";
				
                
                schema.Columns.Add(colvarIsAnonymous);
                
                TableSchema.TableColumn colvarLastActivityDate = new TableSchema.TableColumn(schema);
                colvarLastActivityDate.ColumnName = "LastActivityDate";
                colvarLastActivityDate.DataType = DbType.DateTime;
                colvarLastActivityDate.MaxLength = 0;
                colvarLastActivityDate.AutoIncrement = false;
                colvarLastActivityDate.IsNullable = false;
                colvarLastActivityDate.IsPrimaryKey = false;
                colvarLastActivityDate.IsForeignKey = false;
                colvarLastActivityDate.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarLastActivityDate);
                
                TableSchema.TableColumn colvarPassword = new TableSchema.TableColumn(schema);
                colvarPassword.ColumnName = "Password";
                colvarPassword.DataType = DbType.String;
                colvarPassword.MaxLength = 128;
                colvarPassword.AutoIncrement = false;
                colvarPassword.IsNullable = false;
                colvarPassword.IsPrimaryKey = false;
                colvarPassword.IsForeignKey = false;
                colvarPassword.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarPassword);
                
                TableSchema.TableColumn colvarPasswordFormat = new TableSchema.TableColumn(schema);
                colvarPasswordFormat.ColumnName = "PasswordFormat";
                colvarPasswordFormat.DataType = DbType.Int32;
                colvarPasswordFormat.MaxLength = 0;
                colvarPasswordFormat.AutoIncrement = false;
                colvarPasswordFormat.IsNullable = true;
                colvarPasswordFormat.IsPrimaryKey = false;
                colvarPasswordFormat.IsForeignKey = false;
                colvarPasswordFormat.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarPasswordFormat);
                
                TableSchema.TableColumn colvarPasswordSalt = new TableSchema.TableColumn(schema);
                colvarPasswordSalt.ColumnName = "PasswordSalt";
                colvarPasswordSalt.DataType = DbType.String;
                colvarPasswordSalt.MaxLength = 128;
                colvarPasswordSalt.AutoIncrement = false;
                colvarPasswordSalt.IsNullable = true;
                colvarPasswordSalt.IsPrimaryKey = false;
                colvarPasswordSalt.IsForeignKey = false;
                colvarPasswordSalt.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarPasswordSalt);
                
                TableSchema.TableColumn colvarMobilePIN = new TableSchema.TableColumn(schema);
                colvarMobilePIN.ColumnName = "MobilePIN";
                colvarMobilePIN.DataType = DbType.String;
                colvarMobilePIN.MaxLength = 16;
                colvarMobilePIN.AutoIncrement = false;
                colvarMobilePIN.IsNullable = true;
                colvarMobilePIN.IsPrimaryKey = false;
                colvarMobilePIN.IsForeignKey = false;
                colvarMobilePIN.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarMobilePIN);
                
                TableSchema.TableColumn colvarEmail = new TableSchema.TableColumn(schema);
                colvarEmail.ColumnName = "Email";
                colvarEmail.DataType = DbType.String;
                colvarEmail.MaxLength = 256;
                colvarEmail.AutoIncrement = false;
                colvarEmail.IsNullable = true;
                colvarEmail.IsPrimaryKey = false;
                colvarEmail.IsForeignKey = false;
                colvarEmail.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarEmail);
                
                TableSchema.TableColumn colvarLoweredEmail = new TableSchema.TableColumn(schema);
                colvarLoweredEmail.ColumnName = "LoweredEmail";
                colvarLoweredEmail.DataType = DbType.String;
                colvarLoweredEmail.MaxLength = 256;
                colvarLoweredEmail.AutoIncrement = false;
                colvarLoweredEmail.IsNullable = true;
                colvarLoweredEmail.IsPrimaryKey = false;
                colvarLoweredEmail.IsForeignKey = false;
                colvarLoweredEmail.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarLoweredEmail);
                
                TableSchema.TableColumn colvarPasswordQuestion = new TableSchema.TableColumn(schema);
                colvarPasswordQuestion.ColumnName = "PasswordQuestion";
                colvarPasswordQuestion.DataType = DbType.String;
                colvarPasswordQuestion.MaxLength = 256;
                colvarPasswordQuestion.AutoIncrement = false;
                colvarPasswordQuestion.IsNullable = true;
                colvarPasswordQuestion.IsPrimaryKey = false;
                colvarPasswordQuestion.IsForeignKey = false;
                colvarPasswordQuestion.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarPasswordQuestion);
                
                TableSchema.TableColumn colvarPasswordAnswer = new TableSchema.TableColumn(schema);
                colvarPasswordAnswer.ColumnName = "PasswordAnswer";
                colvarPasswordAnswer.DataType = DbType.String;
                colvarPasswordAnswer.MaxLength = 128;
                colvarPasswordAnswer.AutoIncrement = false;
                colvarPasswordAnswer.IsNullable = true;
                colvarPasswordAnswer.IsPrimaryKey = false;
                colvarPasswordAnswer.IsForeignKey = false;
                colvarPasswordAnswer.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarPasswordAnswer);
                
                TableSchema.TableColumn colvarIsApproved = new TableSchema.TableColumn(schema);
                colvarIsApproved.ColumnName = "IsApproved";
                colvarIsApproved.DataType = DbType.Boolean;
                colvarIsApproved.MaxLength = 0;
                colvarIsApproved.AutoIncrement = false;
                colvarIsApproved.IsNullable = false;
                colvarIsApproved.IsPrimaryKey = false;
                colvarIsApproved.IsForeignKey = false;
                colvarIsApproved.IsReadOnly = false;
                
						colvarIsApproved.DefaultSetting = @"((0))";
				
                
                schema.Columns.Add(colvarIsApproved);
                
                TableSchema.TableColumn colvarIsLockedOut = new TableSchema.TableColumn(schema);
                colvarIsLockedOut.ColumnName = "IsLockedOut";
                colvarIsLockedOut.DataType = DbType.Boolean;
                colvarIsLockedOut.MaxLength = 0;
                colvarIsLockedOut.AutoIncrement = false;
                colvarIsLockedOut.IsNullable = false;
                colvarIsLockedOut.IsPrimaryKey = false;
                colvarIsLockedOut.IsForeignKey = false;
                colvarIsLockedOut.IsReadOnly = false;
                
						colvarIsLockedOut.DefaultSetting = @"((0))";
				
                
                schema.Columns.Add(colvarIsLockedOut);
                
                TableSchema.TableColumn colvarCreateDate = new TableSchema.TableColumn(schema);
                colvarCreateDate.ColumnName = "CreateDate";
                colvarCreateDate.DataType = DbType.DateTime;
                colvarCreateDate.MaxLength = 0;
                colvarCreateDate.AutoIncrement = false;
                colvarCreateDate.IsNullable = false;
                colvarCreateDate.IsPrimaryKey = false;
                colvarCreateDate.IsForeignKey = false;
                colvarCreateDate.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarCreateDate);
                
                TableSchema.TableColumn colvarLastLoginDate = new TableSchema.TableColumn(schema);
                colvarLastLoginDate.ColumnName = "LastLoginDate";
                colvarLastLoginDate.DataType = DbType.DateTime;
                colvarLastLoginDate.MaxLength = 0;
                colvarLastLoginDate.AutoIncrement = false;
                colvarLastLoginDate.IsNullable = true;
                colvarLastLoginDate.IsPrimaryKey = false;
                colvarLastLoginDate.IsForeignKey = false;
                colvarLastLoginDate.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarLastLoginDate);
                
                TableSchema.TableColumn colvarLastPasswordChangedDate = new TableSchema.TableColumn(schema);
                colvarLastPasswordChangedDate.ColumnName = "LastPasswordChangedDate";
                colvarLastPasswordChangedDate.DataType = DbType.DateTime;
                colvarLastPasswordChangedDate.MaxLength = 0;
                colvarLastPasswordChangedDate.AutoIncrement = false;
                colvarLastPasswordChangedDate.IsNullable = true;
                colvarLastPasswordChangedDate.IsPrimaryKey = false;
                colvarLastPasswordChangedDate.IsForeignKey = false;
                colvarLastPasswordChangedDate.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarLastPasswordChangedDate);
                
                TableSchema.TableColumn colvarLastLockoutDate = new TableSchema.TableColumn(schema);
                colvarLastLockoutDate.ColumnName = "LastLockoutDate";
                colvarLastLockoutDate.DataType = DbType.DateTime;
                colvarLastLockoutDate.MaxLength = 0;
                colvarLastLockoutDate.AutoIncrement = false;
                colvarLastLockoutDate.IsNullable = true;
                colvarLastLockoutDate.IsPrimaryKey = false;
                colvarLastLockoutDate.IsForeignKey = false;
                colvarLastLockoutDate.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarLastLockoutDate);
                
                TableSchema.TableColumn colvarFailedPasswordAttemptCount = new TableSchema.TableColumn(schema);
                colvarFailedPasswordAttemptCount.ColumnName = "FailedPasswordAttemptCount";
                colvarFailedPasswordAttemptCount.DataType = DbType.Int32;
                colvarFailedPasswordAttemptCount.MaxLength = 0;
                colvarFailedPasswordAttemptCount.AutoIncrement = false;
                colvarFailedPasswordAttemptCount.IsNullable = true;
                colvarFailedPasswordAttemptCount.IsPrimaryKey = false;
                colvarFailedPasswordAttemptCount.IsForeignKey = false;
                colvarFailedPasswordAttemptCount.IsReadOnly = false;
                
						colvarFailedPasswordAttemptCount.DefaultSetting = @"((0))";
				
                
                schema.Columns.Add(colvarFailedPasswordAttemptCount);
                
                TableSchema.TableColumn colvarFailedPasswordAttemptWindowStart = new TableSchema.TableColumn(schema);
                colvarFailedPasswordAttemptWindowStart.ColumnName = "FailedPasswordAttemptWindowStart";
                colvarFailedPasswordAttemptWindowStart.DataType = DbType.DateTime;
                colvarFailedPasswordAttemptWindowStart.MaxLength = 0;
                colvarFailedPasswordAttemptWindowStart.AutoIncrement = false;
                colvarFailedPasswordAttemptWindowStart.IsNullable = true;
                colvarFailedPasswordAttemptWindowStart.IsPrimaryKey = false;
                colvarFailedPasswordAttemptWindowStart.IsForeignKey = false;
                colvarFailedPasswordAttemptWindowStart.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarFailedPasswordAttemptWindowStart);
                
                TableSchema.TableColumn colvarFailedPasswordAnswerAttemptCount = new TableSchema.TableColumn(schema);
                colvarFailedPasswordAnswerAttemptCount.ColumnName = "FailedPasswordAnswerAttemptCount";
                colvarFailedPasswordAnswerAttemptCount.DataType = DbType.Int32;
                colvarFailedPasswordAnswerAttemptCount.MaxLength = 0;
                colvarFailedPasswordAnswerAttemptCount.AutoIncrement = false;
                colvarFailedPasswordAnswerAttemptCount.IsNullable = false;
                colvarFailedPasswordAnswerAttemptCount.IsPrimaryKey = false;
                colvarFailedPasswordAnswerAttemptCount.IsForeignKey = false;
                colvarFailedPasswordAnswerAttemptCount.IsReadOnly = false;
                
						colvarFailedPasswordAnswerAttemptCount.DefaultSetting = @"((0))";
				
                
                schema.Columns.Add(colvarFailedPasswordAnswerAttemptCount);
                
                TableSchema.TableColumn colvarFailedPasswordAnswerAttemptWindowStart = new TableSchema.TableColumn(schema);
                colvarFailedPasswordAnswerAttemptWindowStart.ColumnName = "FailedPasswordAnswerAttemptWindowStart";
                colvarFailedPasswordAnswerAttemptWindowStart.DataType = DbType.DateTime;
                colvarFailedPasswordAnswerAttemptWindowStart.MaxLength = 0;
                colvarFailedPasswordAnswerAttemptWindowStart.AutoIncrement = false;
                colvarFailedPasswordAnswerAttemptWindowStart.IsNullable = true;
                colvarFailedPasswordAnswerAttemptWindowStart.IsPrimaryKey = false;
                colvarFailedPasswordAnswerAttemptWindowStart.IsForeignKey = false;
                colvarFailedPasswordAnswerAttemptWindowStart.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarFailedPasswordAnswerAttemptWindowStart);
                
                TableSchema.TableColumn colvarComment = new TableSchema.TableColumn(schema);
                colvarComment.ColumnName = "Comment";
                colvarComment.DataType = DbType.String;
                colvarComment.MaxLength = 1073741823;
                colvarComment.AutoIncrement = false;
                colvarComment.IsNullable = true;
                colvarComment.IsPrimaryKey = false;
                colvarComment.IsForeignKey = false;
                colvarComment.IsReadOnly = false;
                
                
                schema.Columns.Add(colvarComment);
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["MembershipProvider"].AddSchema("UserMembership",schema);
            }

        }

        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }

	    #endregion
	    
	    #region .ctors
	    public UserMembership()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }

        
        public UserMembership(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}

			MarkNew();
	    }

	    public UserMembership(object keyID)
	    {
		    SetSQLProps();
            SetDefaults();
		    LoadByKey(keyID);
	    }

    	 
	    public UserMembership(string columnName, object columnValue)
        {
            SetSQLProps();
            SetDefaults();
            LoadByParam(columnName,columnValue);
        }

        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("UserId")]
        public int UserId 
	    {
		    get { return GetColumnValue<int>("UserId"); }

            set 
		    {
			    SetColumnValue("UserId", value);
            }

        }

	      
        [XmlAttribute("UserName")]
        public string UserName 
	    {
		    get { return GetColumnValue<string>("UserName"); }

            set 
		    {
			    SetColumnValue("UserName", value);
            }

        }

	      
        [XmlAttribute("LoweredUserName")]
        public string LoweredUserName 
	    {
		    get { return GetColumnValue<string>("LoweredUserName"); }

            set 
		    {
			    SetColumnValue("LoweredUserName", value);
            }

        }

	      
        [XmlAttribute("MobileAlias")]
        public string MobileAlias 
	    {
		    get { return GetColumnValue<string>("MobileAlias"); }

            set 
		    {
			    SetColumnValue("MobileAlias", value);
            }

        }

	      
        [XmlAttribute("IsAnonymous")]
        public bool IsAnonymous 
	    {
		    get { return GetColumnValue<bool>("IsAnonymous"); }

            set 
		    {
			    SetColumnValue("IsAnonymous", value);
            }

        }

	      
        [XmlAttribute("LastActivityDate")]
        public DateTime LastActivityDate 
	    {
		    get { return GetColumnValue<DateTime>("LastActivityDate"); }

            set 
		    {
			    SetColumnValue("LastActivityDate", value);
            }

        }

	      
        [XmlAttribute("Password")]
        public string Password 
	    {
		    get { return GetColumnValue<string>("Password"); }

            set 
		    {
			    SetColumnValue("Password", value);
            }

        }

	      
        [XmlAttribute("PasswordFormat")]
        public int? PasswordFormat 
	    {
		    get { return GetColumnValue<int?>("PasswordFormat"); }

            set 
		    {
			    SetColumnValue("PasswordFormat", value);
            }

        }

	      
        [XmlAttribute("PasswordSalt")]
        public string PasswordSalt 
	    {
		    get { return GetColumnValue<string>("PasswordSalt"); }

            set 
		    {
			    SetColumnValue("PasswordSalt", value);
            }

        }

	      
        [XmlAttribute("MobilePIN")]
        public string MobilePIN 
	    {
		    get { return GetColumnValue<string>("MobilePIN"); }

            set 
		    {
			    SetColumnValue("MobilePIN", value);
            }

        }

	      
        [XmlAttribute("Email")]
        public string Email 
	    {
		    get { return GetColumnValue<string>("Email"); }

            set 
		    {
			    SetColumnValue("Email", value);
            }

        }

	      
        [XmlAttribute("LoweredEmail")]
        public string LoweredEmail 
	    {
		    get { return GetColumnValue<string>("LoweredEmail"); }

            set 
		    {
			    SetColumnValue("LoweredEmail", value);
            }

        }

	      
        [XmlAttribute("PasswordQuestion")]
        public string PasswordQuestion 
	    {
		    get { return GetColumnValue<string>("PasswordQuestion"); }

            set 
		    {
			    SetColumnValue("PasswordQuestion", value);
            }

        }

	      
        [XmlAttribute("PasswordAnswer")]
        public string PasswordAnswer 
	    {
		    get { return GetColumnValue<string>("PasswordAnswer"); }

            set 
		    {
			    SetColumnValue("PasswordAnswer", value);
            }

        }

	      
        [XmlAttribute("IsApproved")]
        public bool IsApproved 
	    {
		    get { return GetColumnValue<bool>("IsApproved"); }

            set 
		    {
			    SetColumnValue("IsApproved", value);
            }

        }

	      
        [XmlAttribute("IsLockedOut")]
        public bool IsLockedOut 
	    {
		    get { return GetColumnValue<bool>("IsLockedOut"); }

            set 
		    {
			    SetColumnValue("IsLockedOut", value);
            }

        }

	      
        [XmlAttribute("CreateDate")]
        public DateTime CreateDate 
	    {
		    get { return GetColumnValue<DateTime>("CreateDate"); }

            set 
		    {
			    SetColumnValue("CreateDate", value);
            }

        }

	      
        [XmlAttribute("LastLoginDate")]
        public DateTime? LastLoginDate 
	    {
		    get { return GetColumnValue<DateTime?>("LastLoginDate"); }

            set 
		    {
			    SetColumnValue("LastLoginDate", value);
            }

        }

	      
        [XmlAttribute("LastPasswordChangedDate")]
        public DateTime? LastPasswordChangedDate 
	    {
		    get { return GetColumnValue<DateTime?>("LastPasswordChangedDate"); }

            set 
		    {
			    SetColumnValue("LastPasswordChangedDate", value);
            }

        }

	      
        [XmlAttribute("LastLockoutDate")]
        public DateTime? LastLockoutDate 
	    {
		    get { return GetColumnValue<DateTime?>("LastLockoutDate"); }

            set 
		    {
			    SetColumnValue("LastLockoutDate", value);
            }

        }

	      
        [XmlAttribute("FailedPasswordAttemptCount")]
        public int? FailedPasswordAttemptCount 
	    {
		    get { return GetColumnValue<int?>("FailedPasswordAttemptCount"); }

            set 
		    {
			    SetColumnValue("FailedPasswordAttemptCount", value);
            }

        }

	      
        [XmlAttribute("FailedPasswordAttemptWindowStart")]
        public DateTime? FailedPasswordAttemptWindowStart 
	    {
		    get { return GetColumnValue<DateTime?>("FailedPasswordAttemptWindowStart"); }

            set 
		    {
			    SetColumnValue("FailedPasswordAttemptWindowStart", value);
            }

        }

	      
        [XmlAttribute("FailedPasswordAnswerAttemptCount")]
        public int FailedPasswordAnswerAttemptCount 
	    {
		    get { return GetColumnValue<int>("FailedPasswordAnswerAttemptCount"); }

            set 
		    {
			    SetColumnValue("FailedPasswordAnswerAttemptCount", value);
            }

        }

	      
        [XmlAttribute("FailedPasswordAnswerAttemptWindowStart")]
        public DateTime? FailedPasswordAnswerAttemptWindowStart 
	    {
		    get { return GetColumnValue<DateTime?>("FailedPasswordAnswerAttemptWindowStart"); }

            set 
		    {
			    SetColumnValue("FailedPasswordAnswerAttemptWindowStart", value);
            }

        }

	      
        [XmlAttribute("Comment")]
        public string Comment 
	    {
		    get { return GetColumnValue<string>("Comment"); }

            set 
		    {
			    SetColumnValue("Comment", value);
            }

        }

	    
	    #endregion
	    
	    
	    #region PrimaryKey Methods
	    
		public SubSonicMembershipProvider.DataObjects.UserRoleCollection UserRoleRecords()
		{
			return new SubSonicMembershipProvider.DataObjects.UserRoleCollection().Where(UserRole.Columns.UserId, UserId).Load();
		}

		#endregion
		
	 	
			
	    
	    //no foreign key tables defined (0)
	    
	    
	    
	    #region Many To Many Helpers
	    
	     
        public SubSonicMembershipProvider.DataObjects.RoleCollection GetRoleCollection() {
            return UserMembership.GetRoleCollection(this.UserId);
        }

        public static SubSonicMembershipProvider.DataObjects.RoleCollection GetRoleCollection(int varUserId) {
            SubSonic.QueryCommand cmd = new SubSonic.QueryCommand(
                "SELECT * FROM Role INNER JOIN UserRole ON "+
                "Role.RoleId=UserRole.RoleId WHERE UserRole.UserId=@UserId", UserMembership.Schema.Provider.Name);
            
            cmd.AddParameter("@UserId", varUserId, DbType.Int32);
            
            IDataReader rdr = SubSonic.DataService.GetReader(cmd);
            RoleCollection coll = new RoleCollection();
            coll.LoadAndCloseReader(rdr);
            return coll;
        }

        public static void SaveRoleMap(int varUserId, RoleCollection items) {
            
            QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
            //delete out the existing
            QueryCommand cmdDel = new QueryCommand("DELETE FROM UserRole WHERE UserId=@UserId", UserMembership.Schema.Provider.Name);
            cmdDel.AddParameter("@UserId", varUserId);
            //add this in
            coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
            foreach (Role item in items)
            {
				UserRole varUserRole = new UserRole();
				varUserRole.SetColumnValue("UserId", varUserId);
				varUserRole.SetColumnValue("RoleId", item.GetPrimaryKeyValue());
				varUserRole.Save();
            }

        }

        public static void SaveRoleMap(int varUserId, System.Web.UI.WebControls.ListItemCollection itemList) 
        {
            QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
            //delete out the existing
             QueryCommand cmdDel = new QueryCommand("DELETE FROM UserRole WHERE UserId=@UserId", UserMembership.Schema.Provider.Name);
            cmdDel.AddParameter("@UserId", varUserId);
            //add this in
            coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
            foreach (System.Web.UI.WebControls.ListItem l in itemList) 
            {
                if (l.Selected) 
                {
					UserRole varUserRole = new UserRole();
					varUserRole.SetColumnValue("UserId", varUserId);
					varUserRole.SetColumnValue("RoleId", l.Value);
					varUserRole.Save();
                }

            }

        }

        public static void SaveRoleMap(int varUserId , int[] itemList) 
        {
            QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
            //delete out the existing
             QueryCommand cmdDel = new QueryCommand("DELETE FROM UserRole WHERE UserId=@UserId", UserMembership.Schema.Provider.Name);
            cmdDel.AddParameter("@UserId", varUserId);
            //add this in
            coll.Add(cmdDel);
			DataService.ExecuteTransaction(coll);
            foreach (int item in itemList) 
            {
            	UserRole varUserRole = new UserRole();
				varUserRole.SetColumnValue("UserId", varUserId);
				varUserRole.SetColumnValue("RoleId", item);
				varUserRole.Save();
            }

        }

        
        public static void DeleteRoleMap(int varUserId) 
        {
            QueryCommand cmdDel = new QueryCommand("DELETE FROM UserRole WHERE UserId=@UserId", UserMembership.Schema.Provider.Name);
            cmdDel.AddParameter("@UserId", varUserId);
            DataService.ExecuteQuery(cmdDel);
		}

	    
	    #endregion
	    
	    #region ObjectDataSource support
    	
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
	    public static void Insert(string varUserName,string varLoweredUserName,string varMobileAlias,bool varIsAnonymous,DateTime varLastActivityDate,string varPassword,int? varPasswordFormat,string varPasswordSalt,string varMobilePIN,string varEmail,string varLoweredEmail,string varPasswordQuestion,string varPasswordAnswer,bool varIsApproved,bool varIsLockedOut,DateTime varCreateDate,DateTime? varLastLoginDate,DateTime? varLastPasswordChangedDate,DateTime? varLastLockoutDate,int? varFailedPasswordAttemptCount,DateTime? varFailedPasswordAttemptWindowStart,int varFailedPasswordAnswerAttemptCount,DateTime? varFailedPasswordAnswerAttemptWindowStart,string varComment)
	    {
		    UserMembership item = new UserMembership();
		    
            item.UserName = varUserName;
            
            item.LoweredUserName = varLoweredUserName;
            
            item.MobileAlias = varMobileAlias;
            
            item.IsAnonymous = varIsAnonymous;
            
            item.LastActivityDate = varLastActivityDate;
            
            item.Password = varPassword;
            
            item.PasswordFormat = varPasswordFormat;
            
            item.PasswordSalt = varPasswordSalt;
            
            item.MobilePIN = varMobilePIN;
            
            item.Email = varEmail;
            
            item.LoweredEmail = varLoweredEmail;
            
            item.PasswordQuestion = varPasswordQuestion;
            
            item.PasswordAnswer = varPasswordAnswer;
            
            item.IsApproved = varIsApproved;
            
            item.IsLockedOut = varIsLockedOut;
            
            item.CreateDate = varCreateDate;
            
            item.LastLoginDate = varLastLoginDate;
            
            item.LastPasswordChangedDate = varLastPasswordChangedDate;
            
            item.LastLockoutDate = varLastLockoutDate;
            
            item.FailedPasswordAttemptCount = varFailedPasswordAttemptCount;
            
            item.FailedPasswordAttemptWindowStart = varFailedPasswordAttemptWindowStart;
            
            item.FailedPasswordAnswerAttemptCount = varFailedPasswordAnswerAttemptCount;
            
            item.FailedPasswordAnswerAttemptWindowStart = varFailedPasswordAnswerAttemptWindowStart;
            
            item.Comment = varComment;
            
	    
		    if (System.Web.HttpContext.Current != null)
			    item.Save(System.Web.HttpContext.Current.User.Identity.Name);
		    else
			    item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
	    }

    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
	    public static void Update(int varUserId,string varUserName,string varLoweredUserName,string varMobileAlias,bool varIsAnonymous,DateTime varLastActivityDate,string varPassword,int? varPasswordFormat,string varPasswordSalt,string varMobilePIN,string varEmail,string varLoweredEmail,string varPasswordQuestion,string varPasswordAnswer,bool varIsApproved,bool varIsLockedOut,DateTime varCreateDate,DateTime? varLastLoginDate,DateTime? varLastPasswordChangedDate,DateTime? varLastLockoutDate,int? varFailedPasswordAttemptCount,DateTime? varFailedPasswordAttemptWindowStart,int varFailedPasswordAnswerAttemptCount,DateTime? varFailedPasswordAnswerAttemptWindowStart,string varComment)
	    {
		    UserMembership item = new UserMembership();
		    
                item.UserId = varUserId;
				
                item.UserName = varUserName;
				
                item.LoweredUserName = varLoweredUserName;
				
                item.MobileAlias = varMobileAlias;
				
                item.IsAnonymous = varIsAnonymous;
				
                item.LastActivityDate = varLastActivityDate;
				
                item.Password = varPassword;
				
                item.PasswordFormat = varPasswordFormat;
				
                item.PasswordSalt = varPasswordSalt;
				
                item.MobilePIN = varMobilePIN;
				
                item.Email = varEmail;
				
                item.LoweredEmail = varLoweredEmail;
				
                item.PasswordQuestion = varPasswordQuestion;
				
                item.PasswordAnswer = varPasswordAnswer;
				
                item.IsApproved = varIsApproved;
				
                item.IsLockedOut = varIsLockedOut;
				
                item.CreateDate = varCreateDate;
				
                item.LastLoginDate = varLastLoginDate;
				
                item.LastPasswordChangedDate = varLastPasswordChangedDate;
				
                item.LastLockoutDate = varLastLockoutDate;
				
                item.FailedPasswordAttemptCount = varFailedPasswordAttemptCount;
				
                item.FailedPasswordAttemptWindowStart = varFailedPasswordAttemptWindowStart;
				
                item.FailedPasswordAnswerAttemptCount = varFailedPasswordAnswerAttemptCount;
				
                item.FailedPasswordAnswerAttemptWindowStart = varFailedPasswordAnswerAttemptWindowStart;
				
                item.Comment = varComment;
				
		    item.IsNew = false;
		    if (System.Web.HttpContext.Current != null)
			    item.Save(System.Web.HttpContext.Current.User.Identity.Name);
		    else
			    item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
	    }

	    #endregion
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string UserId = @"UserId";
            
            public static string UserName = @"UserName";
            
            public static string LoweredUserName = @"LoweredUserName";
            
            public static string MobileAlias = @"MobileAlias";
            
            public static string IsAnonymous = @"IsAnonymous";
            
            public static string LastActivityDate = @"LastActivityDate";
            
            public static string Password = @"Password";
            
            public static string PasswordFormat = @"PasswordFormat";
            
            public static string PasswordSalt = @"PasswordSalt";
            
            public static string MobilePIN = @"MobilePIN";
            
            public static string Email = @"Email";
            
            public static string LoweredEmail = @"LoweredEmail";
            
            public static string PasswordQuestion = @"PasswordQuestion";
            
            public static string PasswordAnswer = @"PasswordAnswer";
            
            public static string IsApproved = @"IsApproved";
            
            public static string IsLockedOut = @"IsLockedOut";
            
            public static string CreateDate = @"CreateDate";
            
            public static string LastLoginDate = @"LastLoginDate";
            
            public static string LastPasswordChangedDate = @"LastPasswordChangedDate";
            
            public static string LastLockoutDate = @"LastLockoutDate";
            
            public static string FailedPasswordAttemptCount = @"FailedPasswordAttemptCount";
            
            public static string FailedPasswordAttemptWindowStart = @"FailedPasswordAttemptWindowStart";
            
            public static string FailedPasswordAnswerAttemptCount = @"FailedPasswordAnswerAttemptCount";
            
            public static string FailedPasswordAnswerAttemptWindowStart = @"FailedPasswordAnswerAttemptWindowStart";
            
            public static string Comment = @"Comment";
            
	    }

	    #endregion
    }

}

